package com.lzw.breadknife.sample.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.lzw.breadknife.BindClick;
import com.lzw.breadknife.BindView;
import com.lzw.breadknife.BreadKnife;
import com.lzw.breadknife.Unbinder;
import com.lzw.breadknife.sample.R;

/**
 * author  : AWeiLoveAndroid
 * e-mail  : lzw460433675@163.com
 * github  : https://gitee.com/AWeiLoveAndroid/BreadKnife
 * project : BreadKnife
 */
public abstract class BaseActivity<T extends Unbinder> extends AppCompatActivity {
    T unBinder;
    @BindView(R.id.toolBar_title)
    TextView toolBar_title;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        unBinder = (T) BreadKnife.bind(this);
        toolBar_title.setText(attachTitleRes());
        initView();
    }

    protected void initView() {
    }


    @BindClick(R.id.toolBar_back)
    public void OnBackClick(View v) {
        finish();
    }

    protected abstract int attachTitleRes();

    protected void startActivity(Class<? extends AppCompatActivity> clazz) {
        Intent intent = new Intent(this, clazz);
        startActivity(intent);
    }
}
